#!/usr/bin/python
# -*- coding: utf-8 -*-
#  REVISIONS
# 210928 add auto find latest file
#
import time
time.sleep(1)
import os

os.chdir('/home/pi/Documents/GTC-codes')

for r,d,f in os.walk('.'):
    break #get files in current dir
import re
pat=re.compile(r'\d{6}.+.py')
filtered=[i for i in f if pat.match(i)]
filtered.sort()
#print(filtered)

filename=filtered[-1]
print(f'Detected latest file: {filename}')

import io
with io.open(filename,'r',encoding='utf-8') as f:
    txt=f.read() 
exec(txt)
    